package team.knowers.firm.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import team.knowers.firm.common.convention.result.Result;
import team.knowers.firm.common.convention.result.Results;
import team.knowers.firm.dao.entity.PaymentDO;
import team.knowers.firm.dto.req.PagePaymentInfoReqDTO;
import team.knowers.firm.service.PaymentService;

@RestController
@RequiredArgsConstructor
public class PaymentController {
    private final PaymentService paymentService;

    @GetMapping("/api/firm/getAllPayments")
    public Result<IPage<PaymentDO>> getAllPayments(PagePaymentInfoReqDTO pagePaymentInfoReqDTO) {
        return Results.success(paymentService.getAllPaymentsPage(pagePaymentInfoReqDTO));
    }
    @GetMapping("/api/firm/getPaidAllPayments")
    public Result<IPage<PaymentDO>> getPaidPayments(PagePaymentInfoReqDTO pagePaymentInfoReqDTO) {
        return Results.success(paymentService.getPaidPaymentsPage(pagePaymentInfoReqDTO));
    }
    @GetMapping("/api/firm/getUnPaidAllPayments")
    public Result<IPage<PaymentDO>> getUnPaidPayments(PagePaymentInfoReqDTO pagePaymentInfoReqDTO) {
        return Results.success(paymentService.getUnpaidPaymentsPage(pagePaymentInfoReqDTO));
    }
    @GetMapping("/api/firm/getCanceledAllPayments")
    public Result<IPage<PaymentDO>> getCanceledPayments(PagePaymentInfoReqDTO pagePaymentInfoReqDTO) {
        return Results.success(paymentService.getCanceledPaymentsPage(pagePaymentInfoReqDTO));
    }
}
